Skip to content

Fix/657 raster w2da missing vals#869

Open
nimra06 wants to merge 2 commits into
pysal:mainfrom
nimra06:fix/657-raster-w2da-missing-vals
Open

Fix/657 raster w2da missing vals#869
nimra06 wants to merge 2 commits into
pysal:mainfrom
nimra06:fix/657-raster-w2da-missing-vals

Conversation

@nimra06

@nimra06 nimra06 commented Feb 6, 2026

Copy link
Copy Markdown
  1. You have run tests on this submission locally using pytest on your changes. Continuous integration will be run on all PRs with GitHub Actions, but it is good practice to test changes locally prior to a making a PR.
  2. This pull request is directed to the pysal/master branch.
  3. This pull introduces new functionality covered by
    docstrings and
    unittests?
  4. You have assigned a
    reviewer
    and added relevant labels
  5. The justification for this PR is:
    The issue turned out to be that when a raster has missing values, w2da() was being given data with the wrong length, usually the full flattened grid instead of just the valid cells. That caused a pretty confusing shape mismatch error. I added a guard to make sure the data length matches len(w.index) with a clearer error message that points out you need to pass only valid cell values. I also added two tests: one that actually hits the missing-values code path in _index2da and another that confirms we now raise a proper error when flattened data is passed in.

Fixes #657

@codecov

codecov Bot commented Feb 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.5%. Comparing base (7304239) to head (880e8bf).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #869   +/-   ##
=====================================
  Coverage   85.5%   85.5%           
=====================================
  Files        151     151           
  Lines      16092   16115   +23     
=====================================
+ Hits       13758   13782   +24     
+ Misses      2334    2333    -1     
Files with missing lines Coverage Δ
libpysal/weights/raster.py 61.1% <100.0%> (+0.6%) ⬆️
libpysal/weights/tests/test_raster.py 100.0% <100.0%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libpysal/weights/raster.py missing test coverage

1 participant